<template>
  <el-upload
    class="upload-demo"
    :action="uploadUrl"
    :headers="token"
    :show-file-list="true"
    :limit="limit"
    :multiple="isMultiple"
    :on-success="handleSuccess"
  >
    <div class="el-upload__text">点击上传</div>
  </el-upload>
</template>

<script>
import { getToken } from "@/utils/auth";

export default {
  props: {
    uploadUrl: {
      type: String,
      default: "http://192.168.1.5:8080/assess/testVideo/upload",
    },
    limit: {
      type: Number,
      default: 1,
    },
    isMultiple: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      token: {
        Authorization: getToken(),
      },
    };
  },
  methods: {
    handleSuccess(res) {
      if (res.code == 200) {
        this.$emit("success", res.data);
      }
    },
  },
};
</script>
<style lang="less"></style>
